/**
 * jims
 */
package com.jims.master.modules.med.entity;

import com.jims.master.common.persistence.DataEntity;
import com.jims.master.common.utils.IdGen;
import com.jims.master.modules.oper.entity.PriceList;
import com.jims.master.modules.sys.utils.UserUtils;
import org.hibernate.validator.constraints.Length;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 消费Entity
 * @author 陈晓阳
 * @version 2017-05-22
 */
public class MedicalCardConsumeMaster extends DataEntity<MedicalCardConsumeMaster> {
	
	private static final long serialVersionUID = 1L;
	private String patientId;		// patient_id
	private String cardNo;		// card_no
	private double consumeMoney;		// 消费金额
	private double balance;		// 余额
	private String rcptNo;		// 收据号
	private String clinicItemDictId;		// 诊疗项目id
	private String itemClass;		// 项目类别
	private String feeFlag;		// 消费退费标志  0 消费 1 退费
	private String feeId;		// 收费信息记录id 用于退费
	private String expand1;		// expand1
	private String expand2;		// expand2
	private String expand3;		// expand3
    private List<MedicalCardConsumeDetail> medicalCardConsumeDetailList=new ArrayList<MedicalCardConsumeDetail>();
//	private String orgId;		// 机构ID
	private  MedicalCardConsumeDetail medicalCardConsumeDetail=null;

	public MedicalCardConsumeMaster() {
		super();
	}

	public MedicalCardConsumeMaster(String id){
		super(id);
	}

	@Length(min=1, max=64, message="patient_id长度必须介于 1 和 64 之间")
	public String getPatientId() {
		return patientId;
	}

	public void setPatientId(String patientId) {
		this.patientId = patientId;
	}
	
	@Length(min=1, max=64, message="card_no长度必须介于 1 和 64 之间")
	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}
	
	public double getConsumeMoney() {
		return consumeMoney;
	}

	public void setConsumeMoney(double consumeMoney) {
		this.consumeMoney = consumeMoney;
	}
	
	public double getBalance() {
		return balance;
	}

	public void setBalance(double balance) {
		this.balance = balance;
	}
	
	@Length(min=1, max=64, message="收据号长度必须介于 1 和 64 之间")
	public String getRcptNo() {
		return rcptNo;
	}

	public void setRcptNo(String rcptNo) {
		this.rcptNo = rcptNo;
	}
	
	@Length(min=1, max=64, message="诊疗项目id长度必须介于 1 和 64 之间")
	public String getClinicItemDictId() {
		return clinicItemDictId;
	}

	public void setClinicItemDictId(String clinicItemDictId) {
		this.clinicItemDictId = clinicItemDictId;
	}
	
	@Length(min=1, max=64, message="项目类别长度必须介于 1 和 64 之间")
	public String getItemClass() {
		return itemClass;
	}

	public void setItemClass(String itemClass) {
		this.itemClass = itemClass;
	}
	
	@Length(min=0, max=2, message="消费退费标志  0 消费 1 退费长度必须介于 0 和 2 之间")
	public String getFeeFlag() {
		return feeFlag;
	}

	public void setFeeFlag(String feeFlag) {
		this.feeFlag = feeFlag;
	}
	
	@Length(min=1, max=64, message="收费信息记录id 用于退费长度必须介于 1 和 64 之间")
	public String getFeeId() {
		return feeId;
	}

	public void setFeeId(String feeId) {
		this.feeId = feeId;
	}
	
	@Length(min=0, max=64, message="expand1长度必须介于 0 和 64 之间")
	public String getExpand1() {
		return expand1;
	}

	public void setExpand1(String expand1) {
		this.expand1 = expand1;
	}
	
	@Length(min=0, max=64, message="expand2长度必须介于 0 和 64 之间")
	public String getExpand2() {
		return expand2;
	}

	public void setExpand2(String expand2) {
		this.expand2 = expand2;
	}
	
	@Length(min=0, max=64, message="expand3长度必须介于 0 和 64 之间")
	public String getExpand3() {
		return expand3;
	}

	public void setExpand3(String expand3) {
		this.expand3 = expand3;
	}



    public List<MedicalCardConsumeDetail> getMedicalCardConsumeDetailList() {
        return medicalCardConsumeDetailList;
    }

    public void setMedicalCardConsumeDetailList(List<MedicalCardConsumeDetail> medicalCardConsumeDetailList) {
        this.medicalCardConsumeDetailList = medicalCardConsumeDetailList;
    }


    public MedicalCardConsumeDetail getMedicalCardConsumeDetail() {
        return medicalCardConsumeDetail;
    }

    public void setMedicalCardConsumeDetail(MedicalCardConsumeDetail medicalCardConsumeDetail) {
        this.medicalCardConsumeDetail = medicalCardConsumeDetail;
    }

    public void setData(PriceList priceList){
        medicalCardConsumeDetail=new MedicalCardConsumeDetail();
        medicalCardConsumeDetail.setMasterId(getId());
        medicalCardConsumeDetail.setConsumeMoney((priceList.getPrice() * priceList.getAmount()));
        medicalCardConsumeDetail.setItemPrice(priceList.getPrice());
        medicalCardConsumeDetail.setItemClass(priceList.getItemClass());
        medicalCardConsumeDetail.setAmount(priceList.getAmount());
        medicalCardConsumeDetail.setPriceId(priceList.getId());
        medicalCardConsumeDetail.setItemName(priceList.getItemName());
    }


    public void setLoss(double consumeMoney) {
        this.setIsNewRecord(true);
        this.setId(IdGen.uuid());
        this.setConsumeMoney(-consumeMoney);
        this.setRemarks("退费");
        this.setCreateDate(new Date());
        this.setCreateBy(UserUtils.getUser());
     }
}